﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Web;
using DataAccessLayer;

namespace ServiceLayer.Entity
{
    [DataContract]
    public class StockHistoryW
    {
        int stockHistoryID;
        string itemCode;
        string date;
        string description;
        int adjustedQty;
        int balance;

        [DataMember]
        public int StockHistoryID
        {
            get { return stockHistoryID; }
            set { stockHistoryID = value; }
        }

        [DataMember]
        public string ItemCode
        {
            get { return itemCode; }
            set { itemCode = value; }
        }

        [DataMember]
        public string Date
        {
            get { return date; }
            set { date = value; }
        }

        [DataMember]
        public string Description
        {
            get { return description; }
            set { description = value; }
        }

        [DataMember]
        public int AdjustedQty
        {
            get { return adjustedQty; }
            set { adjustedQty = value; }
        }

        [DataMember]
        public int Balance
        {
            get { return balance; }
            set { balance = value; }
        }

        public static StockHistoryW convert(StockHistory stockHistory)
        {
            StockHistoryW u = new StockHistoryW();

            u.StockHistoryID = stockHistory.StockHistoryID;
            u.ItemCode = stockHistory.ItemCode;
            u.Date = stockHistory.Date.GetValueOrDefault().ToString();
            u.Description = stockHistory.Description;
            u.AdjustedQty = stockHistory.AdjustedQty.GetValueOrDefault();
            u.Balance = stockHistory.Balance.GetValueOrDefault();

            return u;
        }

        public static List<StockHistoryW> convertList(List<StockHistory> list)
        {
            List<StockHistoryW> listW = new List<StockHistoryW>();

            foreach (StockHistory x in list)
            {
                listW.Add(convert(x));
            }
            return listW;
        }
    }
}